import allure
from selenium.webdriver.common.by import By

from Base.Base import Base


class Page(Base):
    yq1 = (By.XPATH, '//*[@id="normalLoginTab"]/h2')


    def dy1(self):
        return self.get_text(self.yq1)

    frame1_loc = (By.XPATH, '//iframe[starts-with(@id,"x-URS-iframe17")]')

    @allure.step('第一次进入iframe框架')
    def go_frame1(self):
        self.iframe(self.frame1_loc)

    name_loc = (By.XPATH, '/html/body/div[2]/div[2]/div[2]/form/div/div[1]/div[2]/input')

    @allure.step('输入邮箱')
    def name_input(self):
        self.send_keys(self.name_loc, 'L17800382573')

    pwd_koc = (By.XPATH, '/html/body/div[2]/div[2]/div[2]/form/div/div[3]/div[2]/input[2]')

    @allure.step('输入密码')
    def pwd_input(self):
        self.send_keys(self.pwd_koc, '050208LIU.')

    login_loc = (By.XPATH, '//*[@id="dologin"]')

    @allure.step('点击登录并退出框架')
    def login(self):
        self.click(self.login_loc)
        self.iframe2()

    xie_loc = (By.XPATH, '/html/body/div[1]/nav/div[1]/ul/li[2]/span[2]')

    @allure.step('点击写信')
    def xie(self):
        self.click(self.xie_loc)

    shou_loc = (By.XPATH, '/html/body/div[2]/div[1]/div[2]/div[1]/section/header/div[1]/div[1]/div/div[2]/div/input')

    @allure.step('输入收信人')
    def shou(self):
        self.send_keys(self.shou_loc, '2017681094@qq.com')

    zhuti_loc = (By.XPATH, '/html/body/div[2]/div[1]/div[2]/div[1]/section/header/div[2]/div[1]/div/div/input')

    @allure.step('输入主题')
    def zhuti(self):
        self.send_keys(self.zhuti_loc, '主题')

    frame2_loc = (By.XPATH, '/html/body/div[2]/div[1]/div[2]/div[1]/section/section/div/div[1]/div[1]/div[2]/iframe')

    @allure.step('第二次进入iframe框架')
    def go_frame2_loc(self):
        self.iframe(self.frame2_loc)

    body_loc = (By.XPATH, '/html/body')

    @allure.step('输入内容并退出框架')
    def send_body(self):
        self.send_keys(self.body_loc, '内容')
        self.iframe2()

    send_loc = (By.XPATH, '/html/body/div[2]/div[1]/div[2]/div[1]/section/footer/div[1]/span[2]')

    def fasong(self):
        self.click(self.send_loc)
